Merged
Conversation
Three fixes for issue #184: 1. Menubar Swift code used UTC instead of local timezone in two places: computeHistoryStats hardcoded TimeZone("UTC") and effectiveTokensInLast7Days used ISO8601DateFormatter (UTC default). Both now use .current to match CLI-produced local date keys. 2. Add --timezone flag and CODEBURN_TZ env var to override the system timezone for all date grouping. Sets process.env.TZ before any Date operations so all existing local-timezone code works unchanged. 3. Replace MS_PER_DAY arithmetic with Date constructor day-of-month math for yesterday/backfill computations. Subtracting 86400000ms from midnight skips a day on DST spring-forward (23-hour day). Fixes #184
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
computeHistoryStatsin FindingsSection.swift hardcodedTimeZone(identifier: "UTC")andeffectiveTokensInLast7Daysin AppStore.swift usedISO8601DateFormatter()(UTC default). Both now use.currentto match the CLI's local-timezone date keys. This caused streaks, week deltas, and projections to be off by a day for non-UTC users.--timezoneflag: New global--timezone <zone>option (andCODEBURN_TZenv var) lets users override the system timezone for all date grouping. Setsprocess.env.TZbefore any Date operations so all existing code works unchanged. Useful for Docker, CI, cron, or viewing data in a different timezone.todayStart.getTime() - MS_PER_DAYwithnew Date(y, m, d - 1)for yesterday/backfill computations. Subtracting 86400000ms from midnight skips a day on DST spring-forward (23-hour day).Test plan
npx tsx src/cli.ts report --period today --format json --timezone Asia/Singaporeoutputs correct local datenpx tsx src/cli.ts report --period today --format json --timezone Asia/Seouloutputs correct local datenpx tsx src/cli.ts report --timezone InvalidZoneprints error and exits 1CODEBURN_TZ=Asia/Tokyo npx tsx src/cli.ts report --period today --format jsonpicks up env varnpx tsc --noEmitpassesswift buildpasses for menubar appFixes #184